home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Libraries / tcl7.4b3 / doc / ExprLong.3 < prev    next >
Encoding:
Text File  |  1995-02-22  |  3.7 KB  |  107 lines

  1. '\"
  2. '\" Copyright (c) 1989-1993 The Regents of the University of California.
  3. '\" Copyright (c) 1994-1995 Sun Microsystems, Inc.
  4. '\"
  5. '\" See the file "license.terms" for information on usage and redistribution
  6. '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '\" 
  8. '\" @(#) ExprLong.3 1.14 95/02/22 14:37:17
  9. '\" 
  10. .so man.macros
  11. .HS Tcl_ExprLong tclc 7.0
  12. .BS
  13. .SH NAME
  14. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString \- evaluate an expression
  15. .SH SYNOPSIS
  16. .nf
  17. \fB#include <tcl.h>\fR
  18. .sp
  19. int
  20. \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
  21. .sp
  22. int
  23. \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
  24. .sp
  25. int
  26. \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
  27. .sp
  28. int
  29. \fBTcl_ExprString\fR(\fIinterp, string\fR)
  30. .SH ARGUMENTS
  31. .AS Tcl_Interp *booleanPtr
  32. .AP Tcl_Interp *interp in
  33. Interpreter in whose context to evaluate \fIstring\fR.
  34. .AP char *string in
  35. Expression to be evaluated.  Must be in writable memory (the expression
  36. parser makes temporary modifications to the string during parsing, which
  37. it undoes before returning).
  38. .AP long *longPtr out
  39. Pointer to location in which to store the integer value of the
  40. expression.
  41. .AP int *doublePtr out
  42. Pointer to location in which to store the floating-point value of the
  43. expression.
  44. .AP int *booleanPtr out
  45. Pointer to location in which to store the 0/1 boolean value of the
  46. expression.
  47. .BE
  48.  
  49. .SH DESCRIPTION
  50. .PP
  51. These four procedures all evaluate an expression, returning
  52. the result in one of four different forms.
  53. The expression is given by the \fIstring\fR argument, and it
  54. can have any of the forms accepted by the \fBexpr\fR command.
  55. The \fIinterp\fR argument refers to an interpreter used to
  56. evaluate the expression (e.g. for variables and nested Tcl
  57. commands) and to return error information.  \fIInterp->result\fR
  58. is assumed to be initialized in the standard fashion when any
  59. of the procedures are invoked.
  60. .PP
  61. For all of these procedures the return value is a standard
  62. Tcl result:  \fBTCL_OK\fR means the expression was successfully
  63. evaluated, and \fBTCL_ERROR\fR means that an error occurred while
  64. evaluating the expression.  If \fBTCL_ERROR\fR is returned then
  65. \fIinterp->result\fR will hold a message describing the error.
  66. If an error occurs while executing a Tcl command embedded in
  67. the expression then that error will be returned.
  68. .PP
  69. If the expression is successfully evaluated, then its value is
  70. returned in one of four forms, depending on which procedure
  71. is invoked.
  72. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
  73. If the expression's actual value is a floating-point number,
  74. then it is truncated to an integer.
  75. If the expression's actual value is a non-numeric string then
  76. an error is returned.
  77. .PP
  78. \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
  79. If the expression's actual value is an integer, it is converted to
  80. floating-point.
  81. If the expression's actual value is a non-numeric string then
  82. an error is returned.
  83. .PP
  84. \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
  85. If the expression's actual value is an integer or floating-point
  86. number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if
  87. the value was zero and 1 otherwise.
  88. .VS
  89. If the expression's actual value is a non-numeric string then
  90. it must be one of the values accepted by \fBTcl_GetBoolean\fR,
  91. such as ``yes'' or ``no'', or else an error occurs.
  92. .VE
  93. .PP
  94. \fBTcl_ExprString\fR returns the value of the expression as a
  95. string stored in \fIinterp->result\fR.
  96. .VS
  97. If the expression's actual value is an integer
  98. then \fBTcl_ExprString\fR converts it to a string using \fBsprintf\fR
  99. with a ``%d'' converter.
  100. If the expression's actual value is a floating-point
  101. number, then \fBTcl_ExprString\fR calls \fBTcl_PrintDouble\fR
  102. to convert it to a string.
  103. .VE
  104.  
  105. .SH KEYWORDS
  106. boolean, double, evaluate, expression, integer, string
  107.